// 枚举
export const originOption = ref({
  "Base.BaseAsinList.TransportationTypeEnum": [],
  review_type: {
    2: [
      { label: "计划经理审核", value: "PLAN_DIRECTOR_PASS" },
      { label: "计划经理审核不通过", value: "PLAN_DIRECTOR_REJECT" },
    ],
    3: [
      { label: "运营经理审核", value: "OPERATIONS_PASS" },
      { label: "运营经理审核不通过", value: "OPERATIONS_REJECT" },
    ],
    4: [
      { label: "运营总监审核", value: "OPERATIONS_DIRECTOR_PASS" },
      { label: "运营总监审核不通过", value: "OPERATIONS_DIRECTOR_REJECT" },
    ],
    10: [
      { label: "供应链总监审核通过", value: "SUPPLY_CHAIN_DIRECTOR_PASS" },
      { label: "供应链总监审核不通过", value: "SUPPLY_CHAIN_DIRECTOR_REJECT" },
    ],
  },
})

const estimated_shipping_time = ref("")
// 操作
export const handleFunctions = ref({})
const reviewColor = {
  已驳回: "base-tag-danger",
  已审核: "base-tag-info",
}
const activityColor = {
  新品: "text-green",
  重点: "text-red",
}
// 备货计划明细  列
export const stockUpPlanColumns = reactive([
  {
    title: "备货计划信息",
    width: 250,
    slots: {
      default: ({ row }) => (
        <div>
          <VText value={row.stocking_plan?.pr_number} line={1} type="link" />
          <VText title="计划名称" value={row.stocking_plan?.plan_name} line={1} />
          <VText title="计划类型" value={row.stocking_plan?.plan_type_text} line={1} />
          <VText title="计划部门" value={row.stocking_plan?.planning_department} line={1} />
        </div>
      ),
    },
  },
  {
    title: "图片",
    width: 110,
    slots: {
      default: ({ row }) => <el-image style="width:80px;height:80px" src={row.sku_attr_img} />,
    },
  },
  {
    title: "商品信息",
    width: 220,
    slots: {
      default: ({ row }) => (
        <div>
          <div class="flex items-center">
            <div class="flex mr-[4px] ">
              <div class={`status-tag  mr-[2px] ${reviewColor[row.review_status_text] || "base-tag-warning"}`}>{row.review_status_text}</div>
            </div>
            <div class="text-blue flex-1">SKU: {row.sku}</div>
          </div>
          <VText title="自定义" value={row.custom_sku} line={1} />
          <VText title="ASIN" value={row.asin} line={1} />
          <div class="grid grid-cols-2">
            <VText title="国家" value={row.site_code} line={1} />
            <VText title="活跃度" value={row.activity_status_text} line={1} class={activityColor[row.activity_status_text]} />
          </div>
        </div>
      ),
    },
  },
  {
    title: "商品名称",
    width: 240,
    field: "sku_title",
    line: 2,
  },

  {
    title: "需求数量",
    width: 120,
    slots: {
      default: ({ row }) => (
        <div>
          {/* <el-input v-model={row.spa_analysis.stocking_quantity} placeholder="需求数量" style="width: 80px" onblur={() => handleFunctions?.value?.updateQuantity(row)} /> */}
          <el-input-number
            min={0}
            max={9999999}
            precision={0}
            controls={false}
            v-model={row.spa_analysis.stocking_quantity}
            onchange={() => handleFunctions?.value?.updateQuantity(row)}
            placeholder="需求数量"
            style="width:100px"
          />
        </div>
      ),
    },
  },
  {
    title: "总金额/RMB",
    width: 120,
    slots: {
      default: ({ row }) => <div>¥ {row.spa_analysis?.total_amount}</div>,
    },
  },
  {
    title: "基础LT天数",
    width: 340,
    slots: {
      default: ({ row }) => (
        <div>
          <div class="cursor-pointer text-[#3487ff]">{row?.spa_lt_days?.basic_lead_time}天</div>
          <div class="grid grid-cols-2">
            <VText title="采购天数" value={row?.spa_lt_days.procurement_days ? row?.spa_lt_days.procurement_days + "天" : ""} line={1} />
            <VText title="运输天数" value={row?.spa_lt_days.procurement_days ? row?.spa_lt_days.transportation_days + "天" : ""} line={1} />
            <VText title="安全天数" value={row?.spa_lt_days.safety_days ? row?.spa_lt_days.safety_days + "天" : ""} line={1} />

            <VText title="采购处理天数" value={row?.spa_lt_days.procurement_processing_days ? row?.spa_lt_days.procurement_processing_days + "天" : ""} line={1} />

            <VText title="本地仓处理天数" value={row?.spa_lt_days.local_warehouse_processing_days ? row?.spa_lt_days.local_warehouse_processing_days + "天" : ""} line={1} />
            <VText title="海外中转仓处理天" value={row?.spa_lt_days.overseas_transit_warehouse_processing_days ? row?.spa_lt_days.overseas_transit_warehouse_processing_days + "天" : ""} line={1} />
            <VText title="平台上架天数" value={row?.spa_lt_days.platform_listing_days ? row?.spa_lt_days.platform_listing_days + "天" : ""} line={1} />
          </div>
        </div>
      ),
    },
  },

  {
    title: "库存可售天数",
    width: 240,
    slots: {
      default: ({ row }) => (
        <div>
          <div>{row?.spa_inventory_availability.total_inventory_days} 天</div>
          <div class="grid grid-cols-2">
            <VText title="FBA可售" value={row?.spa_inventory_availability.fba_sellable ? row?.spa_inventory_availability.fba_sellable + "天" : ""} line={1} />
            <VText title="FBA在途" value={row?.spa_inventory_availability.fba_in_transit ? row?.spa_inventory_availability.fba_in_transit + "天" : ""} line={1} />
            <VText title="海外仓在途" value={row?.spa_inventory_availability.overseas_warehouse_in_transit ? row?.spa_inventory_availability.overseas_warehouse_in_transit + "天" : ""} line={1} />
            <VText title="海外仓可用" value={row?.spa_inventory_availability.overseas_warehouse_available ? row?.spa_inventory_availability.overseas_warehouse_available + "天" : ""} line={1} />
          </div>
        </div>
      ),
    },
  },
  {
    title: "库存信息",
    width: 240,
    slots: {
      default: ({ row }) => (
        <div class="grid grid-cols-2">
          <VText title="FBA可用" value={row?.spa_inventory.fba_available} line={1} />
          <VText title="本地仓可用" value={row?.spa_inventory.local_warehouse_available} line={1} />
          <VText title="本地仓待发" value={row?.spa_inventory.local_warehouse_pending_shipment} line={1} />
          <VText title="海外仓可用" value={row?.spa_inventory.overseas_warehouse_available} line={1} />
          <VText title="采购在途" value={row?.spa_inventory.procurement_in_transit} line={1} />
          <VText title="FBA在途" value={row?.spa_inventory.fba_in_transit} line={1} />
          <VText title="海外仓在途" value={row?.spa_inventory.overseas_transit_in_transit} line={1} />
        </div>
      ),
    },
  },
  {
    title: "销量信息",
    width: 160,
    slots: {
      default: ({ row }) => (
        <div class="grid grid-cols-2">
          <VText title="7天" value={row?.spa_sales.sales_num_seven_days} line={1} />
          <VText title="14天" value={row?.spa_sales.sales_num_fourteen_days} line={1} />
          <VText title="30天" value={row?.spa_sales.sales_num_thirty_days} line={1} />
          <VText title="90天" value={row?.spa_sales.sales_num_ninety_days} line={1} />
          <svg-icon icon-class="tubiao" class="text-[#3487ff] text-[1.5em]" onClick={() => handleFunctions?.value?.openTendencyChart(row)} />
        </div>
      ),
    },
  },

  {
    title: "预估日均销量",
    width: 120,
    slots: {
      default: ({ row }) => (
        <div>
          <VText title="系统" value={row.system_average_daily_sales} line={1} type="link" />
          <VText title="运营" value={row.operation_average_daily_sales} line={1} type="link" />
        </div>
      ),
    },
  },
  {
    title: "运输类型",
    width: 180,
    slots: {
      default: ({ row }) => (
        <div>
          <div class="flex items-center mb-[4px]">
            <el-select v-model={row.transportation_type} placeholder="请选择" onChange={() => handleFunctions?.value?.updateTransportation(row)} class="mr-[4px]" style="width:80px">
              {originOption.value?.["Base.BaseAsinList.TransportationTypeEnum"]?.map((d) => (
                <el-option label={d.label} value={d.value} />
              ))}
            </el-select>
            <span>{row?.spa_lt_days.transportation_days || "-"}天</span>
          </div>
          <VText title="最近FBA到货 x" value={row.xxx} line={1} />
          <VText title="到货时间 x" value={row.xxx} line={1} />
        </div>
      ),
    },
  },

  {
    title: "采购信息",
    width: 240,
    slots: {
      default: ({ row }) => (
        <div>
          <div class="grid grid-cols-2">
            <VText title="采购价" value={row.spa_purchases?.purchase_price} line={1} />
            <div>
              <el-divider direction="vertical" />
              {row.spa_purchases?.min_order_quantity}起批
            </div>
          </div>
          <VText title="采购天数" value={row.spa_purchases?.purchase_days} line={1} />
          <VText title="单箱数量" value={row.spa_purchases?.mpq_min_quantity} line={1} />
          <VText title="供应商" value={row.spa_purchases?.supplier_name} line={1} />
        </div>
      ),
    },
  },

  {
    title: "人员信息",
    width: 240,
    slots: {
      default: ({ row }) => (
        <div>
          <VText title="计划" value={row.planner_user_text} line={1} />
          <VText title="采购" value={row.purchaser_user_text} line={1} />
          <VText title="运营" value={row.operator_user_text} line={1} />
          <VText title="部门" value={row.department_name} line={2} />
        </div>
      ),
    },
  },
  {
    title: "预计发货时间",
    width: 200,
    slots: {
      header: ({ row }) => (
        <div class="text-center mb-[4px]">
          预计发货时间
          <div class="flex">
            <el-date-picker v-model={estimated_shipping_time.value} class="date-picker" type="date" placeholder="请选择" value-format="YYYY-MM-DD" style="width:140px" />
            <el-button type="primary" onClick={() => handleFunctions?.value?.batchShipTimeChange(estimated_shipping_time.value)}>
              修改
            </el-button>
          </div>
        </div>
      ),

      default: ({ row }) => (
        <div>
          <el-date-picker
            class="date-picker"
            v-model={row.estimated_shipping_time}
            type="date"
            placeholder="请选择"
            value-format="YYYY-MM-DD"
            onChange={() => handleFunctions?.value?.shipTimeChange(row)}
            style="width:140px"
          />
        </div>
      ),
    },
  },
  {
    title: "备料库存 x",
    width: 180,
    slots: {
      default: ({ row }) => (
        <div>
          <VText title="需要备料" value={row.xxx} line={1} />
          <VText title="库存" value={row.xxx} line={1} />
        </div>
      ),
    },
  },
  {
    title: "备注信息",
    width: 160,
    slots: {
      default: ({ row }) => (
        <div class="flex" onClick={() => handleFunctions?.value?.editRemark(row)}>
          <svg-icon icon-class="edit_icon" class="mr-[2px] text-blue mt-[4px]"></svg-icon>
          <VText value={row.remark || "-"} line={2} />
        </div>
      ),
    },
  },
])

// 表单编辑 弹窗配置
export const currentConfirmOpt = reactive({
  // 审核
  audit: {
    title: "审核",
    formOptions: { labelPosition: "right", labelWidth: "140px" },
    fieldOptions: [
      {
        field: "review_type",
        label: "审核状态",
        type: "select",
        originField: "review_type",
        style: { width: "300px" },
      },
    ],
    rules: {
      review_type: [{ required: true, message: "请选择", trigger: "change" }],
    },
    tips: "说明：可针对“待计划审核、待运营审核”状态的SKU操作",
  },
  // 备注
  remark: {
    title: "备注",
    fieldOptions: [
      {
        field: "remark",
        type: "textarea",
        label: "备注",
        style: { width: "100%" },
        autosize: { minRows: 4, maxRows: 6 },
        full: true,
      },
    ],
    rules: {
      review_type: [{ required: true, message: "请选择", trigger: "change" }],
    },
  },
})
